package com.nq.controller.backend;

import com.nq.common.ServerResponse;
import com.nq.pojo.StPremarketStock;
import com.nq.pojo.vo.StPremarketStockVo;
import com.nq.service.IStPremarketStockService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@RequestMapping({"/admin/premarket/"})
public class AdminStockPremarket {

    @Resource
    private IStPremarketStockService premarketStockService;

    /**
     * @Description:  获取盘前交易列表
     * @Param:
     * @return:
     */
    @RequestMapping({"getPremarketStock.do"})
    public ServerResponse getPremarketStock(
            @RequestParam(value = "pageNum", defaultValue = "1") int pageNum,
            @RequestParam(value = "pageSize", defaultValue = "10") int pageSize,
            @RequestParam(value = "stockCode") String stockCode,
            @RequestParam(value = "market") String market
            ) {
        return premarketStockService.getPremarketStock(pageNum, pageSize, stockCode, market);
    }

    /**
     * @Description:  新增盘前交易
     * @Param:
     * @return:
     */
    @RequestMapping({"addPremarketStock.do"})
    public ServerResponse addPremarketStock(@RequestParam(value = "stockCode")String stockCode,
                                     @RequestParam(value = "market")String market,
                                     @RequestParam(value = "startTime")String startTime,
                                     @RequestParam(value = "endTime")String endTime,
                                     @RequestParam(value = "beforeStartTime")String beforeStartTime,
                                     @RequestParam(value = "beforeEndTime")String beforeEndTime,
                                     @RequestParam(value = "price") String price,
                                    @RequestParam(value = "maxPrice") String maxPrice,
                                     @RequestParam(value = "sellMinPrice") String sellMinPrice,
                                    @RequestParam(value = "sellMaxPrice") String sellMaxPrice,
                                            @RequestParam(value = "times") Integer times) {
        return premarketStockService.addPremarketStock(market, stockCode, startTime, endTime, beforeStartTime, beforeEndTime, price, maxPrice, sellMinPrice, sellMaxPrice, times);
    }

    /**
     * 删除盘前交易
     */
    @RequestMapping({"deletePremarketStock.do"})
    public ServerResponse deletePremarketStock(@RequestParam(value = "id") String id) {
        return premarketStockService.deletePremarketStock(id);
    }
    /**
     * 修改盘前交易
     */
    @RequestMapping({"updatePremarketStock.do"})
    public ServerResponse updatePremarketStock(StPremarketStockVo model) {
        return premarketStockService.updatePremarketStock(model);
    }

}
